<template>
	<div class="container">
		<!-- 主导航栏 -->
		<ul class="main-tabs clearfix"  v-show="userinfos.account!='fcwlhyg'">
			<li v-for="(item,index) in mainTabs.data" :key="index" :class="{active:index==mainTabs.index}" @click="mainTabSwitch(index)">{{item.title}}</li>
		</ul>
		<!-- 头部信息 -->
		<h3 class="header-title clearfix">
			<span class="border"></span>
			<p>{{headerTitle}}</p>
			<div class="opt fr clearfix" v-if="mainTabs.index == 3">
				<span @click="entryData.showDialog = true;">手动录入</span>
				<comImport :options="importData" @submitEntry="submitEntry"></comImport>
			</div>
		</h3>
		<!-- 搜索栏 -->
		<comSearch v-if="mainTabs.index == 3" :options="searchData" @search="searchList"></comSearch>
		<!-- 副导航栏 -->
		<comNavTabs :navList="navList" @switch="tabSwitch"></comNavTabs>
		<!-- 数据展示的列表 -->
		<comTable :options="tableList" @openFlexDialog="openFlexDialog" @openRegDialog="openRegDialog"
			@openFailsDialog="openFailsDialog" @openIntentionDialog=openIntentionDialog
			@openQRcodeDialog="function(data){return openUploadDialog('QRcode',data)}"
			@openLicenseDialog="function(data){return openUploadDialog('license',data)}"
			@openCollectionAccount="openCollectionAccount" @cancellationData="cancellationData"
			@delListData="delListData" @modifyFlexDialog="modifyFlexDialog"
		></comTable>
		<!-- 需求详情模板 -->
		<flexDemand :options="flexDemand" :type="mainTabs.index" :nav="navList.index" :individual.sync="flexDemand.type"
			@cooperatFail="cooperatFail" @cooperatPass="cooperatPass" @cooperatDouble="cooperatDouble"
			@cooperatEnd="cooperatEnd" @breakOff="function(){breakOffContract('解约')}"
			@reject="function(){breakOffContract('驳回')}" @confirm="function(){breakOffContract('确认解约')}"
			@updateData="updateData"
		></flexDemand>
		<!-- 个体商户注册信息 -->
		<flexRegisterMsg :options="registerMsg" :nav="navList.index"></flexRegisterMsg>
		<!-- 申报失败弹窗 -->
		<flexUnsuccessful :options="unsuccessfulData" @subFailData="subFailData"
		></flexUnsuccessful>
		<!-- 添加认证二维码和电子营业执照弹窗 -->
		<flexUpload :options="uploadData" @subUploadData="subUploadData"></flexUpload>
		<!-- 收款账户弹窗 -->
		<flexCollectAccount :options="collectionAccountData"></flexCollectAccount>
		<!-- 灵活就业收入-手动录入弹窗 -->
		<flexManualEntry ref="entryDialog" :options="entryData" @submitEntry="function(form){submitEntry(form,'手动')}"></flexManualEntry>
		<!-- 导入弹窗数据展示模板 -->
		<flexImportTemplate :options="templateData" @screenData="function(form){screenData(form,'批量')}"></flexImportTemplate>
		<!-- 分页器 -->
		<div class="pageBox">
			<el-pagination
				@size-change="handleSizeChange"
				@current-change="pageChange"
				:current-page.sync="cur"
				:page-sizes="[10, 20, 30, 50, 100]"
				:page-size="pageSize"
				layout="total, sizes, prev, pager, next, jumper"
				:total="totalNum"
				background
			></el-pagination>
		</div>
	</div>
</template>

<script>
import jobsData from '../../assets/jobs.json';
export default{
	components:{
		comNavTabs: () => import("@/household/common/comNavTabs.vue"),
		comSearch: () => import("@/component/common/comSearch.vue"),
		comImport: () => import("@/component/common/comImport.vue"),
		comTable: () => import("@/household/common/comTable.vue"),
		flexDemand: () => import("@/component/flexible/flexDemand.vue"),
		flexManualEntry: () => import("@/component/flexible/flexManualEntry.vue"),
		flexRegisterMsg: () => import("@/component/flexible/flexRegisterMsg.vue"),
		flexUnsuccessful: () => import("@/component/flexible/flexUnsuccessful.vue"),
		flexUpload: () => import("@/component/flexible/flexUpload.vue"),
		flexCollectAccount: () => import("@/component/flexible/flexCollectAccount.vue"),
		flexImportTemplate: () => import("@/component/flexible/flexImportTemplate.vue"),
	},
	data(){ 
		return {
			/* 主导航栏列表数据 */  
			userinfos:{},
			mainTabs: {
				index:0,		//当前是在哪个tab栏
				data:[
					{title:'企业需求'},
					{title:'报名用户'},
					{title:'个体商户认证'},
					{title:'灵活就业收入'},
				]
			},
			headerTitle: '企业需求',								//头部标题
			/* 副导航栏列表数据 */
			navList:{
				index:0,		//当前是在哪个tab栏
				data:[
					{title:'待处理'},
					{title:'未达成合作'},
					{title:'合作中'},
					{title:'已完成'}
				]	
			},
			/* 手动录入数据 */
			entryData:{
				showDialog: false,								//显示
				
			},
			/* 导入数据 */
			importData:{
				
			},
			/* 搜索栏数据 */
			searchData:{
				noUserName: true,								//会员名称
				noProjectName: true,							//项目名称
				noCardnum: true,								//身份证号码
				noTime: true,									//时间段
				
				searchInfo: {},									//搜索信息
			},
			/* 表格数据 */
			tableList:{
				list:[
					{title:'企业名称',prop:'companyName',isClick:false},
					{title:'联系人手机',prop:'telnum',isClick:false},
					{title:'提交时间',prop:'createTime',isClick:false},
					{title:'需求主题',prop:'projectName',isClick:false},
					{title:'费用标准',prop:'costStandard',isClick:false},
				],
				noOperation:true,	//是否有操作项
				operation:[			//操作项内容
					{name:'操作',isBtn:false,title:'openFlexDialog'}
				],
				data:[
					/* {
						companyName: '上海天都人力资源有限公司',
						telnum: '15202120781',
						createTime: '2020-10-12',
						projectName: '帮助公司设计官方网站',
						costStandard: '5000元',
					} */
				]
			},
			/* 需求详情模板数据 */
			flexDemand:{
				showDialog: false,										//显示
				type: '',												//类型
				mold: '',												//合作中还是修改数据
				projectMsg:{
					/* companyName: '天都人力资源有限公司',					//公司名称
					companyAddress: '上海-上海-闵行区',						//公司地址
					telnum: '13434343434',									//电话号码
					projectName: '网站界面设计ui',							//主题
					contentStandard: '好嗨呀',								//服务内容标准
					personnelStandard: '感觉人生达到了高潮',					//服务人员标准
					cost: '500',											//费用标准
					settlement: '日结',										//结算方式 */
				},
				dataList: [
					/* {
						userName: '张三',
						operatingResult: '未达成',
						createTime: '2020-10-12',
						postscript: '资料不全，费用太低了',
					} */
				],
			},
			/* 个体商户注册信息数据 */
			registerMsg:{
				showDialog: false,										//显示
				userInfo:{
					/* userName: '张三',										//姓名
					telenum: '13434343434',									//手机号码
					cardnum: '315151515151515',								//身份证号码
					applicantCompany: '天都人力资源有限公司',					//公司名称
					industry: '物流',										//行业
					identitya: 'https://tiandufacai-1259220846.cos.ap-shanghai.myqcloud.com/newimg/766661474528526336.jpg',
					identityb: 'https://tiandufacai-1259220846.cos.ap-shanghai.myqcloud.com/newimg/766661474528526336.jpg',
					serviceCharge: 'https://tiandufacai-1259220846.cos.ap-shanghai.myqcloud.com/newimg/766661474528526336.jpg', */
				}
			},
			/* 申报失败数据 */
			unsuccessfulData:{
				showDialog: false,										//显示
				title: '',												//标题
				userInfo:{},											//用户数据
				eventName: 'subFailData',								//事件名称
			},
			/* 上传文件数据 */
			uploadData:{
				showDialog: false,										//显示
				title: '添加认证二维码',										//弹窗标题
				fileList: [],												//图片列表
				type: '',													//上传类型:营业执照或二维码
				userInfo: {},												//用户信息
			},
			/* 收款账户数据 */
			collectionAccountData: {
				showDialog: false,										//显示
				userInfo:{},											//用户信息
			},
			templateData:{
				showDialog: false,										//显示
				tableList: [],											//校验之后的数据
			},
			
			
			/* 分页功能数据 */
			cur:1,
			pageSize: 10,
			totalNum: 0,				//总共有多少条数据,根据这个数据去适配页数
		}
		
		
	},
	created(){
		this.mainTabSwitch(0);
		this.userinfos = eval("(" + localStorage.getItem('userinfo') + ")");
		console.log(this.userinfos.account);
		console.log(this.userinfos);
	},
	methods:{
		/* 头部主tabs栏切换 */
		mainTabSwitch(index){
			this.mainTabs.index = index;
			this.headerTitle = this.mainTabs.data[index].title;
			if(index == 0){
				this.navList.data = [
					{title:'待处理'},
					{title:'未达成合作'},
					{title:'合作中'},
					{title:'已完成'}
				]
				this.tableList.list = [
					{title:'企业名称',prop:'companyName',isClick:false},
					{title:'联系人手机',prop:'telnum',isClick:false},
					{title:'提交时间',prop:'createTime',isClick:false},
					{title:'需求主题',prop:'projectName',isClick:false},
					{title:'费用标准',prop:'costStandard',isClick:false},
				]
			}else if(index == 1){
				this.navList.data = [
					{title:'待处理'},
					{title:'未达成合作'},
					{title:'合作中'},
					{title:'待确认解约'},
					{title:'中止项目'},
					{title:'完成项目'},
					
				]
				this.tableList.list = [
					{title:'用户名称',prop:'proName',isClick:true,eventName:'openRegDialog'},
					{title:'联系人手机',prop:'telenum',isClick:false},
					{title:'报名时间',prop:'createTime',isClick:false},
					{title:'需求企业',prop:'companyName',isClick:false},
					{title:'需求主题',prop:'projectName',isClick:false},
				]
			}else if(index == 2){
				this.navList.data = [
					{title:'待处理'},
					{title:'个体户注册成功'},
					{title:'个体户申报失败'},
				]
			}else{
				this.navList.data = [];
			}
			this.cur = 1;
			this.pageSize = 10;
			this.tabSwitch(0);
		},
		/* 子tabs栏切换 */
		tabSwitch(index){
			this.navList.index = index;
			this.tableList.operation.splice(0);
			this.tableList.noProjectStatus = false;
			if(this.mainTabs.index == 0 || this.mainTabs.index == 1){
				if(index == 0 || index == 2){
					this.tableList.operation = [
						{name:'操作',isBtn:false,title:'openFlexDialog'}
					]
				}else{
					this.tableList.operation = [
						{name:'查看',isBtn:false,title:'openFlexDialog'}
					]
				}
				if(index == 2){
					this.tableList.operation.push({name:'修改',isBtn:false,title:'modifyFlexDialog'})
				}
			}else if(this.mainTabs.index == 2){
				if(index == 0){
					this.tableList.list = [
						{title:'会员名称',prop:'userName',isClick:false},
						{title:'联系人手机',prop:'telenum',isClick:false},
						{title:'提交时间',prop:'createTime',isClick:false},
						{title:'身份证号码',prop:'cardnum',isClick:false},
						{title:'意向合作项目',prop:'projectName',isClick:true,eventName: 'openIntentionDialog'}
					];
					this.tableList.operation = [
						{name:'查看',isBtn:false,title:'openRegDialog'},
						{name:'收款账户',isBtn:false,title:'openCollectionAccount'},
						{name:'申报失败',isBtn:false,title:'openFailsDialog'},
						{name:'添加认证二维码',isBtn:false,title:'openQRcodeDialog'},
						{name:'添加电子营业执照',isBtn:false,title:'openLicenseDialog'}
					]
				}else{
					this.tableList.list = [
						{title:'会员名称',prop:'userName',isClick:false},
						{title:'联系人手机',prop:'telenum',isClick:false},
						{title:'提交时间',prop:'createTime',isClick:false},
						{title:'身份证号码',prop:'cardnum',isClick:false},
					];
					if(index == 1){
						this.tableList.list.push({title:'项目合作状态',prop:'projectStatus',isClick:true,eventName: 'openFlexDialog'},)
						this.tableList.operation = [
							{name:'查看',isBtn:false,title:'openRegDialog'},
							{name:'收款账户',isBtn:false,title:'openCollectionAccount'},
							{name:'注销',isBtn:false,title:'cancellationData'},
						]
					}else{
						this.tableList.operation = [
							{name:'查看',isBtn:false,title:'openRegDialog'},
							{name:'收款账户',isBtn:false,title:'openCollectionAccount'},
						]
					}
					
				}
			}else{
				this.tableList.list = [
					{title:'会员名称',prop:'businessmanName',isClick:false},
					{title:'身份证号码',prop:'identity',isClick:false},
					{title:'项目名称',prop:'projectName',isClick:false},
					{title:'录入日期',prop:'createTime',isClick:false},
					{title:'收入月份',prop:'incomeTime',isClick:false},
					{title:'收入金额',prop:'revenue',isClick:false},
				];
				this.tableList.operation = [
					{name:'删除',isBtn:false,title:'delListData'}
				]
			}
			this.getDataList();
		},
		/* 搜索条件搜索数据 */
		searchList(form){
			if(form.userName){
				form.businessmanName = form.userName;
				delete form.userName;
			}
			console.log(form);
			this.searchData.searchInfo = form;
			this.getDataList(this.searchData.searchInfo);
		},
		/* 打开银行收款账户弹窗 */
		openCollectionAccount(data){
			console.log(data);
			this.collectionAccountData.userInfo = data;
			this.collectionAccountData.showDialog = true;
		},
		/* 获取数据列表 */
		getDataList(form){
			let params = {
				pageNum: this.cur,
				pageSize: this.pageSize
			}
			let url = '';
			if(this.mainTabs.index == 0){
				params.cooperation = this.navList.index;
				url = '/v1/demand/selectDemandByList';
			}else if(this.mainTabs.index == 1){
				params.cooperation = this.navList.index;
				url = '/v1/businessman/selectAgilityApplyList';
			}else if(this.mainTabs.index == 2){
				params.status = this.navList.index + 1;
				url = '/v1/businessman/selectBusinessmanList';
			}else{
				if(form){Object.assign(params,form)};
				url = '/v1/apply/selectAgilityIncomeList';
			}
			this.$flexibleAxios.post(url,params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.tableList.data = [];
					let result = res.data.data;
					this.totalNum = Number(result.totalNum);
					if(this.mainTabs.index == 3){
						this.tableList.data = result.incomeList;
					}else{
						result.alist.forEach(item => {
							if(item.serviceCharge){
								if(item.payments == '1'){
									item.costStandard = item.serviceCharge + '元/日';
								}else if(item.payments == '2'){
									item.costStandard = item.serviceCharge + '元/月';
								}else if(item.payments == '3'){
									item.costStandard = item.serviceCharge + '元';
								}else if(item.payments == '4'){
									item.costStandard = item.serviceCharge + '元/小时';
								}
							}else{
								item.costStandard = '-';
							}
							
							if(item.companyAddPro){
								item.citys = [item.companyAddPro,item.companyAddCity,item.companyAddCounty];
							}
							if(item.arrange){
								let arr = item.arrange.split(';');
								item.arrangeList = [];
								arr.forEach((num,index) => {
									if(num){
										item.arrangeList.push(
											{
												url: num,
												uid: index
											}
										)
									}
								})
							}else{
								item.arrangeList = [];
							}
							if(item.applyList && item.applyList.length > 0){
								item.projectStatusList = [];
								item.applyList.forEach(sub => {
									if(sub.cooperation == 0){
										sub.title = sub.projectName + '(待处理)';
									}else if(sub.cooperation == 1){
										sub.title = sub.projectName + '(未达成合作)';
									}else if(sub.cooperation == 2){
										sub.title = sub.projectName + '(合作中)';
									}else if(sub.cooperation == 3){
										sub.title = sub.projectName + '(确认合同完成)';
									}else if(sub.cooperation == 4){
										sub.title = sub.projectName + '(合作中止)';
									}else if(sub.cooperation == 5){
										sub.title = sub.projectName + '(合作中)';
									}else if(sub.cooperation == 6){
										sub.title = sub.projectName + '(合作中)';
									}else if(sub.cooperation == 7){
										sub.title = sub.projectName + '(合作中止)';
									}
									item.projectStatusList.push(sub);
								})
							}
							this.tableList.data.push(item);
						})
					}
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
		},
		/* 打开需求详情模板 */
		openFlexDialog(data){
			console.log(data);
			let params = {
				perhapsId: data.demandId,
				distinguish: this.mainTabs.index + 1
			}
			this.$flexibleAxios.post('/v1/demand/selectAgilityOperationList',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					let result = res.data.data;
					this.flexDemand.dataList = result.alist;
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
			
			if(this.mainTabs.index == 0){
				this.flexDemand.mold = 'default';
				this.flexDemand.projectMsg = data;
				this.flexDemand.showDialog = true;
			}else{
				this.$flexibleAxios.post('/v1/businessman/selectAgilityApplyByapplyId',{applyId: data.applyId}).then(res => {
					console.log(res);
					if(res.data.code === 1000){
						let result = res.data.data;
						if(result.payments == '1'){
							result.costStandard = result.serviceCharge + '元/日';
						}else if(result.payments == '2'){
							result.costStandard = result.serviceCharge + '元/月';
						}else if(result.payments == '3'){
							result.costStandard = result.serviceCharge + '元';
						}
						result.citys = [result.companyAddPro,result.companyAddCity,result.companyAddCounty];
						if(result.arrange){
							let arr = result.arrange.split(';');
							result.arrangeList = [];
							arr.forEach((num,index) => {
								if(num){
									result.arrangeList.push(
										{
											url: num,
											uid: index
										}
									)
								}
							})
						}
						this.flexDemand.projectMsg = result;
						this.flexDemand.showDialog = true;
					}else{
						this.$message({
							message: res.data.message,
							type: 'warning'
						})
					}
				})
			}
		},
		/* 企业需求-合作中-修改数据 */
		modifyFlexDialog(data){
			console.log(data);
			this.flexDemand.projectMsg = data;
			this.flexDemand.showDialog = true;
			this.flexDemand.mold = 'modify';
		},
		/* 个体商户认证-待处理-意向合作项目 */
		openIntentionDialog(data){
			console.log(data);
			this.flexDemand.type = 'individual';
			this.$flexibleAxios.post('/v1/demand/selectAgilityDemandBydemandId',{userId: data.userId,demandId: data.demandId}).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					let result = res.data.data;
					if(result.companyAddPro){
						result.citys = [result.companyAddPro,result.companyAddCity,result.companyAddCounty];
					}
					if(result.arrange){
						let arr = result.arrange.split(';');
						result.arrangeList = [];
						arr.forEach((num,index) => {
							if(num){
								result.arrangeList.push(
									{
										url: num,
										uid: index
									}
								)
							}
						})
					}
					this.$set(this.flexDemand,'projectMsg',result);
					this.flexDemand.showDialog = true;
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
			
		},
		/* 打开个体户注册信息模板 */
		openRegDialog(data){
			console.log(data);
			this.$flexibleAxios.post('/v1/businessman/selectBusinessmanIsTrue',{userId: data.userId}).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					let result = res.data.data;
					if(result.industry){
						let arr1 = eval(result.industry);
						let arr2 = [];
						jobsData.industry.forEach(item1 => {
							arr1.forEach(item2 => {
								if(item1.key == item2){
									arr2.push(item1.value + '；');
								}
							})
						})
						result.industryList = arr2;
					}
					this.registerMsg.userInfo = result;
					
					this.registerMsg.showDialog = true;
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
		},
		/* 个体商户认证-个体户注册成功-注销功能 */
		cancellationData(data){
			console.log(data);
			this.$confirm('此操作将删除该账户, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.$flexibleAxios.post('/v1/demand/deleteBusinessman',{userId: data.userId}).then(res => {
					console.log(res);
					if(res.data.code === 1000){
						this.getDataList();
						this.$message({
							type: 'success',
							message: '注销成功'
						});
					}else{
						this.$message({
							type: 'warning',
							message: res.data.message
						});
					}
				})
				
			}).catch(() => {
				this.$message({
					type: 'info',
					message: '已取消注销操作'
				});          
			});
		},
		/* 打开申报失败弹窗 */
		openFailsDialog(data){
			console.log(data);
			this.unsuccessfulData.title = '申报失败';
			this.unsuccessfulData.eventName = 'subFailData';
			this.unsuccessfulData.userInfo = data;
			this.unsuccessfulData.showDialog = true;
		},
		/* 提交企业需求或报名用户-未达成合作数据 */
		cooperatFail(data){
			console.log(data);
			let params = {
				cooperation: 1,
				postscript: data,
				demandId: this.flexDemand.projectMsg.demandId,
				activeUserId: JSON.parse(localStorage.getItem('userinfo')).userid,
				userName: JSON.parse(localStorage.getItem('userinfo')).username,
			}
			let url = '';
			if(this.mainTabs.index == 0){
				url = '/v1/demand/updateDemandByCooperation';
			}else{
				url = '/v1/businessman/updateApplyCooperationByApplyId';
				params.applyId = this.flexDemand.projectMsg.applyId;
			}
			this.$flexibleAxios.post(url,params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.$message({
						message: '操作成功！',
						type: 'success'
					})
					this.flexDemand.showDialog = false;
					this.getDataList();
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
		},
		/* 提交报名用户-达成合作数据 */
		cooperatPass(data){
			console.log(data);
			let params = {
				cooperation: 2,
				postscript: data,
				demandId: this.flexDemand.projectMsg.demandId,
				activeUserId: JSON.parse(localStorage.getItem('userinfo')).userid,
				userName: JSON.parse(localStorage.getItem('userinfo')).username,
				applyId: this.flexDemand.projectMsg.applyId
			}
			this.$flexibleAxios.post('/v1/businessman/updateApplyCooperationByApplyId',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.$message({
						message: '操作成功！',
						type: 'success'
					})
					this.flexDemand.showDialog = false;
					this.getDataList();
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
		},
		/* 提交企业需求-达成合作及展示数据 */
		cooperatDouble(form){
			console.log(form);
			let data = {
				cooperation: 2,
				postscript: form.remarks,
				demandId: form.demandId,
				activeUserId: JSON.parse(localStorage.getItem('userinfo')).userid,
				userName: JSON.parse(localStorage.getItem('userinfo')).username,
			}
			this.$flexibleAxios.post('/v1/demand/updateDemandByCooperation',data).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.updateData(form);
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
		},
		/* 更新数据 */
		updateData(form){
			let params = {
				companyAddPro: form.companyAddPro,
				companyAddCity: form.companyAddCity,
				companyAddCounty: form.companyAddCounty,
				detailedAddress: form.detailedAddress,
				projectName: form.projectName,
				contentStandard: form.contentStandard,
				personnelStandard: form.personnelStandard,
				arrange: form.arrange,
				serviceCharge: form.serviceCharge,
				payments: form.payments,
				demandId: form.demandId,
				projectIntroduction:form.projectIntroduction
			}
			this.$flexibleAxios.post('/v1/demand/updateDemand',params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.$message({
						message: '操作成功！',
						type: 'warning'
					})
					this.flexDemand.showDialog = false;
					this.getDataList();
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
		},
		/* 灵活就业-删除数据操作 */
		delListData(data){
			console.log(data);
			this.$confirm('是否删除此条数据?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.$flexibleAxios.post('/v1/apply/deleteIncomeByIncomeId',{incomeId: data.incomeId}).then(res => {
					console.log(res);
					if(res.data.code === 1000){
						this.$message.success('删除成功!');
						this.getDataList(this.searchData.searchInfo);
					}else{
						this.$message.warning(res.data.message);
					}
				}) 
				
			}).catch(() => {
				this.$message({
					type: 'info',
					message: '已取消删除'
				});          
			});
		},
		/* 企业需求或报名用户-合作中-合作完成操作 */
		cooperatEnd(){
			let params = {},url = '';
			if(this.mainTabs.index == 0){
				params.demandId = this.flexDemand.projectMsg.demandId;
				url = '/v1/demand/updateDemandCooperation';
				this.$flexibleAxios.post(url,params).then(res => {
					console.log(res);
					if(res.data.code === 1000){
						this.$message({
							message: '操作成功！',
							type: 'success'
						})
						this.flexDemand.showDialog = false;
						this.getDataList();
					}else{
						this.$message({
							message: res.data.message,
							type: 'warning'
						})
					}
				})
			}else{
				/* params.applyId = this.flexDemand.projectMsg.applyId;
				url = '/v1/apply/updateApplyFinish'; */
				this.breakOffContract('确认合作完成');
			}
			
		},
		/* 报名用户-合作中-解约操作-原因弹窗 */
		breakOffContract(title){
			this.unsuccessfulData.title = title;
			this.unsuccessfulData.eventName = 'subFailData';
			this.unsuccessfulData.showDialog = true;
		},
		/* 灵活用工就业-提交手动录入数据 和 批量导入数据进行数据校验*/
		submitEntry(arr,type){
			console.log(arr);
			this.$flexibleAxios.post('/v1/apply/selectIsYes',arr).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					if(type == '手动'){
						this.entryData.showDialog = false;
						if(res.data.data[0].exit){
							this.screenData(res.data.data,'手动');
						}else{
							this.$message.warning('录入信息有误，请重新核对后录入');
						}
						this.$refs.entryDialog.resetForm('form');
					}else{
						this.templateData.showDialog = true;
						this.templateData.tableList = res.data.data;
					}
				}else{
					this.$message.warning(res.data.message);
				}
				
				
			})
		},
		/* 灵活用工就业-提交筛选过后的导入数据 */
		screenData(arr,type){
			this.$flexibleAxios.post('/v1/apply/insertIncomeList',arr).then(res =>{
				console.log(res);
				if(res.data.code === 1000){
					this.getDataList(this.searchData.searchInfo);
					this.$message.success('录入成功！');
				}else{
					this.$message.warning(res.data.message);
				}
				if(type == '批量'){
					this.templateData.showDialog = false;
				}else{
					this.entryData.showDialog = false;
				}
			})
		},
		/* 打开上传图片弹窗 */
		openUploadDialog(type,data){
			console.log(type);
			console.log(data);
			this.uploadData.type = type;
			this.uploadData.userInfo = data;
			if(type == 'QRcode'){
				this.uploadData.title = '添加认证二维码';
				if(data.personnelStandard){
					this.uploadData.fileList.push({
						name: 'code.jpg',url: data.personnelStandard
					});
				}else{
					this.uploadData.fileList = [];
				}
			}else{
				this.uploadData.title = '添加电子营业执照';
				this.uploadData.fileList = [];
			}
			
			this.uploadData.showDialog = true;
		},
		/* 提交申报失败数据 */
		subFailData(data){
			let params = {
				contentStandard: data,
				applyId: this.flexDemand.projectMsg.applyId
			},url = '';
			if(this.unsuccessfulData.title == '驳回'){
				url = '/v1/apply/insertTerminateBhJy';
			}else if(this.unsuccessfulData.title == '解约'){
				url = '/v1/apply/backgroundTerminate';
			}else if(this.unsuccessfulData.title == '确认解约'){
				url = '/v1/apply/insertTerminateTyJy';
			}else if(this.unsuccessfulData.title == '确认合作完成'){
				url = '/v1/apply/updateApplyFinish';
				params.finishPostscript = data;
				delete params.contentStandard;
			}else{
				params = {
					businessmanId: this.unsuccessfulData.userInfo.businessmanId,
					userId: this.unsuccessfulData.userInfo.userId,
					postscript: data
				};
				url = '/v1/businessman/updateBusinessmanStatus';
			}
			this.$flexibleAxios.post(url,params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.$message.success('操作成功！');
					this.flexDemand.showDialog = false;
					/* if(this.unsuccessfulData.title == '驳回' || this.unsuccessfulData.title == '解约' || this.unsuccessfulData.title == '确认解约'){
						this.flexDemand.showDialog = false;
					} */
					this.unsuccessfulData.showDialog = false;
					this.getDataList();
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
		},
		/* 提交认证二维码或电子营业执照图片 */
		subUploadData(data){
			console.log(data);
			let params = {
				businessmanId: this.uploadData.userInfo.businessmanId,
				userId: this.uploadData.userInfo.userId,
			}
			let url = '';
			if(this.uploadData.type == 'QRcode'){
				params.personnelStandard = data;
				url = '/v1/businessman/updatePersonnelStandard';
			}else{
				params.serviceCharge = data.url;
				params.applicantCompany = data.applicantCompany;
				url = '/v1/businessman/updateServiceCharge';
			}
			this.$flexibleAxios.post(url,params).then(res => {
				console.log(res);
				if(res.data.code === 1000){
					this.$message({
						message: '信息上传成功！',
						type: 'success'
					})
					this.uploadData.showDialog = false;
					this.getDataList();
				}else{
					this.$message({
						message: res.data.message,
						type: 'warning'
					})
				}
			})
		},
		
		//当前页是第几页,点击的第几页的时候调用这个函数
		pageChange(p) {
			// 点击的时候传过来一个参数，这个参数就是所点击的当前页数，
			// 然后把这个当前页数转换成字符串形式赋值给page，
			// 然后把page这个参数传给search这个方法
			console.log(p);
			this.cur = p;
			this.getDataList();
		},
		//每页有多少条,10,20,50等,点击选择的时候调用这个方法
		handleSizeChange (val) {
			console.log(val);
			this.pageSize = val;
			this.getDataList();
		},
	}
}
</script>

<style scoped="scoped">
.container{background-color: #fff;height: 100%;padding-left: 20px;}
.main-tabs {background-color: #EFF1F8;margin-bottom: 20px;margin-left: -20px;padding-left: 50px;}
.main-tabs li{height: 40px;line-height: 40px;float: left;margin: 10px 20px;padding: 0 30px;cursor: pointer;}
.main-tabs .active{background: #0064E4;border-radius: 20px;color: #fff;}
.header-title{padding: 10px 0 20px 0;border-bottom: 1px solid #D2D2D2;}
.header-title .border{width: 15px;height: 30px;background-color: #0064E4;margin-right: 20px;float: left;}
.header-title p{float: left;font-weight: bold;line-height: 30px;}
.header-title .opt span{float: left;margin-right: 20px;padding: 10px 20px;border: 1px solid #000;border-radius: 20px;cursor: pointer;}
.pageBox{margin-top: 20px;}
</style>
